<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<table class="display" id="example">
	<thead>
		<tr>
			<th>选择</th>
			<th><strong>异动时间</strong></th>
			<th><strong>工号</strong></th>
			<th><strong>姓名</strong></th>
			<th><strong>现部门</strong></th>
			<th><strong>现职位</strong></th>
			<th><strong>现职等职级</strong></th>
			<th><strong>异动部门</strong></th>
			<th><strong>异动职位</strong></th>
			<th><strong>异动职等职级</strong></th>
			<th style="width: 100px;">审核状况</th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.transactions == null || #request.transactions.size() <= 0">
			<tr class="gradeX"> <td colspan="11">暂无数据</td> </tr>
		</s:if>
		<s:else>
			<s:iterator value="#request.transactions" var="t" status="sta">
				<s:if test="#sta.even"> <tr class="gradeA"> </s:if> <s:else> <tr class="gradeC"> </s:else>
				<td><input type="checkbox" name="chk_transactions_${organizationId}" value="${t.id}" /></td>
				<td><s:date name="#request.t.moveDateTiem" format="yyyy-MM-dd"/> </td>
                <td>${t.work.workNo}</td>
                <td>${t.work.baseId.name}</td>
                <td>${t.oldOrganization.fullName}</td>
                <td>${t.oldDuty.dutyName}</td>
                <td>${t.oldGradeLevel.gradeName}${t.oldGradeLevel.gradeSort}</td>
                <td>${t.newOrganization.fullName}</td>
                <td>${t.newDuty.dutyName}</td>
                <td>${t.newGradeLevel.gradeName}${t.newGradeLevel.gradeSort}</td>
				<td>
                    <s:if test="#request.t.status.toString() == 'wait_audit'">
                        <a href="#transaction/audit-${type}.xhtml?transaction.id=${t.id}" class="button"><span class="icon icon-ok" style="background:url(${ctx}/images/img/error.png)">&nbsp;</span>未审核</a>
                    </s:if>
                    <s:elseif test="#request.t.status.toString() == 'within_audit'">
                        <a href="#transaction/audit-${type}.xhtml?transaction.id=${t.id}" class="button"><span class="icon icon-ok" style="background:url(${ctx}/images/img/error.png)">&nbsp;</span>审核中</a>
                    </s:elseif>
                    <s:else>
                        <a href="#" class="button"><span class="icon icon-ok" style="background:url(${ctx}/images/img/accept.png)">&nbsp;</span>已审核</a>
                    </s:else>
				</td>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>

<br/><br/>
<div class="grid_12">
    <div class="form-action clearfix">
        <p>
        <span><input type="checkbox" value="1" id="check_all" style="opacity: 100;" onclick="checkAll(this, 'chk_salary_performance')"></span><label for="check_all">&nbsp;全选</label>

        <button type="submit" class="button" onclick="deleteTransaction()" style="display: none;">批量删除</button>
        <a class="button" href="javascript:void(0)" onclick="edit()"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>修改</a>
        <a class="button" href="javascript:void(0)" onclick="add()"><span style="background:url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加</a>
        </p>
    </div>
</div>

<script type="text/javascript">
    function findCheckTransaction(){
        var checkIds = new Array();
        $("input[type='checkbox'][name='chk_transactions_${organizationId}']").each(function(){
            if(this.checked){
                checkIds.push(this.value);
            }
        });
        return checkIds;
    }

    function edit(){
        var checkIds = findCheckTransaction();
        if(checkIds.length == 0){
            alert("请选择要修改的数据")
            return;
        }
        window.location.href = "#transaction/edit-${type}.xhtml?organizationId=${organizationId}&type=${type}&transaction.id="+checkIds[0];
    }

    function add(){
        window.location.href = "#transaction/add-${type}.xhtml?organizationId=${organizationId}&type=${type}";
    }

    function deleteTransaction(){
        var checkIds = findCheckTransaction();
        if(checkIds.length == 0){
            alert("请选择要删除的数据")
            return;
        }
        if(confirm("确定要删除选择的异动数据吗")){
            window.location.href = "#transaction/delete-${type}.xhtml?organizationId=${organizationId}&type=${type}&transaction_ids="+checkIds.join(",");
        }
    }
</script>